package cn.iocoder.boot.demokeycloakbk.rsa;

import com.auth0.jwt.JWT;
import com.auth0.jwt.JWTVerifier;
import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.interfaces.DecodedJWT;
import java.security.interfaces.RSAPublicKey;

public class JwtVerifier {

    public static void verifyJwt(String token, RSAPublicKey publicKey) {
        JWTVerifier verifier = JWT.require(Algorithm.RSA256(publicKey, null))
            .withIssuer("issuer")
            .build();

        DecodedJWT jwt = verifier.verify(token);
        System.out.println("JWT verified: " + jwt.getSubject());
    }
}
